home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / utils sync / JetSync 1.0 / jetsync-1.0.exe / jetsync-1.0 / src / proc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-27  |  810 b   |  36 lines

  1. #include "proc.h"
  2.  
  3. /* checks for jetsync application processes still running in which case
  4.    synchronization cannot proceed. */
  5. int check_processes()
  6. {
  7.   DIR *d;
  8.   FILE *fp;
  9.   struct dirent *dirp = (struct dirent *) malloc(sizeof(struct dirent));
  10.   char fname[512], str[256];
  11.  
  12.   d = opendir("/proc/");
  13.   while ((dirp = readdir(d))) {
  14.     memset((char *)fname, 0, 512);
  15.     sprintf(fname, "/proc/%s/cmdline", dirp->d_name);
  16.     fp = fopen(fname, "r");
  17.     if (!fp)
  18.       continue;
  19.  
  20.     memset((char *)str, 0, 256);
  21.     fgets(str, 256, fp);
  22.     if (!feof(fp)) continue;
  23.     fclose(fp);
  24.  
  25.     if (strstr(str, "/jetaddr.exe") ||
  26.         strstr(str, "/jetmemo.exe") ||
  27.         strstr(str, "/jettodo.exe") ||
  28.         strstr(str, "ical ")) {
  29.       closedir(d);
  30.       return -1;
  31.     }
  32.   }
  33.   closedir(d);
  34.   return 0;
  35. }
  36.